#ifndef TREE_H
#define TREE_H

// a tree data structure used for Huffman decoding
struct TreeNode{
  TreeNode* leftChild;
  TreeNode* rightChild;
  int weight;
  int symbol;

  explicit TreeNode(): weight(0), symbol(0) {
    leftChild = NULL; 
    rightChild = NULL;
  }

  bool is_leaf(){
    if ((!leftChild) && (!rightChild))
      return true;
    return false;
  }

};

// functor for comparing TreeNode*
struct lt{
  bool operator()(const TreeNode* x, const TreeNode* y) const {
    return ((x -> weight) < (y -> weight));
  }
};



#endif
